package com.apes.fn.server.productRequire;

import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface RequireLogisticsRepository extends CustomRepository<RequireLogistics, String> {
    @Query(value = "SELECT TO_CHAR(CREATE_DATE, 'YYYY-MM-DD HH24:MI:SS') ZXRQ_SJ, MESSAGE\n" +
            "  FROM STOCK_REQUIRE_LOGISTICS\n" +
            " WHERE (ORIGIN = :origin AND PRODUCT_ID IS NULL)\n" +
            "    OR (ORIGIN = :origin AND PRODUCT_ID = :productId)\n" +
            " ORDER BY ID DESC ", nativeQuery = true)
    List<Map> findOneRequireLogistics(@Param("origin") String origin, @Param("productId") String productId);

    @Query(value = "select * from STOCK_REQUIRE_LOGISTICS where source = :source and message = :message ", nativeQuery = true)
    List<RequireLogistics> distinctRequireLogistics(@Param("source") String source, @Param("message") String message);
}






















